{template 'common/header'}
{if IMS_VERSION<1}
<link href="{MODULE_URL}/template/static/css/wq1.0.css" rel="stylesheet">
{/if}
<style>
.thumbnail img{min-width: 20px;min-height: 20px;}
.main_form .we7-form input[type=radio], .main_form .we7-form input[type=checkbox] {
    display: inline-block;
    cursor: pointer;
}
.btn-downpic{
{if $nodownpic==1 }
  display:1none;
  {/if}
}
 .we7-form input[type=radio],  .we7-form input[type=checkbox] {
    display: inline-block;
    cursor: pointer;
}
</style>
<div class="we7-page-title">编辑／新增投票用户</div>
<ul class="we7-page-tab">
	<li{if $_GPC['ty'] == '' && $_GPC['do'] == 'votelist' && $_GPC['ranking'] == ''  } class="active"{/if}><a href="{php echo $this->createWebUrl('votelist',array('rid'=>$_GPC['rid']));}">全部投票</a></li>
    <li{if $_GPC['ty'] == '2'} class="active"{/if}><a href="{php echo $this->createWebUrl('votelist',array('rid'=>$_GPC['rid'],'ty'=>2));}">待审核</a></li>
	<li{if $_GPC['ty'] == '1'} class="active"{/if}><a href="{php echo $this->createWebUrl('votelist',array('rid'=>$_GPC['rid'],'ty'=>1));}">已审核</a></li>
	<li{if $_GPC['ranking'] == '0'} class="active"{/if}><a href="{php echo $this->createWebUrl('votelist',array('rid'=>$_GPC['rid'],'ranking'=>0));}">票数排行</a></li>
	<li{if $_GPC['ranking'] == '1'} class="active"{/if}><a href="{php echo $this->createWebUrl('votelist',array('rid'=>$_GPC['rid'],'ranking'=>1));}">礼物排行</a></li>
	<li{if $_GPC['do'] == 'giftlist'} class="active"{/if}><a href="{php echo $this->createWebUrl('giftlist',array('rid'=>$_GPC['rid']));}">全部订单</a></li>
	<li{if $_GPC['do'] == 'edit'} class="active"{/if}><a href="{php echo $this->createWebUrl('edit',array('id'=>$_GPC['id'],'rid'=>$_GPC['rid']));}">{if $_GPC['id'] > 0}编辑投票用户{else}添加投票用户{/if}</a></li>
</ul>
<div class="we7-form">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form1">
		<div class="panel-body" id="step1">

			<div class="panel-body">
			
			{if $_GPC['id']!=0}
				<div class="form-group">
					<label class="control-label col-sm-2 control-label"><span class="text-danger">*</span> 编号</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="noid" value="{$votedata['noid']}"/>
						<span class="help-block"></span>
					</div>
				</div>
			{/if}
			     <div class="form-group">
				  <label class="control-label col-sm-2 control-label">头像</label>
				  <div class="col-sm-9">
					{php echo tpl_form_field_image('avatar',$votedata['avatar'],'', $options);}
					<div class="help-block">投票显示头像，建议80*80</div>
				  </div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2 control-label"><span class="text-danger">*</span> 姓名</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="name" value="{$votedata['name']}"/>
						<span class="help-block"></span>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2 control-label"><span class="text-danger">*</span> OPEIND</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="oauth_openid" value="{$votedata['oauth_openid']}"/>
						<span class="help-block">通过“粉丝营销”--“粉丝”查询对应的用户openid，不制定用户，可以以留空。</span>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2 control-label"><span class="text-danger">*</span> 借权OPEIND</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="openid" value="{$votedata['openid']}"/>
						<span class="help-block">通过借权的服务号“粉丝营销”--“粉丝”查询对应的用户openid，不制定用户，可以以留空。</span>
					</div>
				</div>
				<div class="form-group">
				{php echo $tplappye;}
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2 control-label">票数</label>
					<div class="col-sm-4">
			            <div class="input-group">
			              <span class="input-group-addon">目前{$votedata['votenum']}票， +</span>
			              <input class="form-control" type="number" value=""name="addvotenum">
			              <span class="input-group-addon">票</span>
			            </div>
			            <span class="help-block">输入需要新增或减少的票数，输入“-10”，等于减少10票，“+”为增，“-”为减。</span>
			          </div>
					
					
				</div>
		<div class="form-group">
		<label class="control-label col-sm-2 control-label">礼物</label>
		<div class="col-sm-4">
            <div class="input-group">
              <span class="input-group-addon">目前{$votedata['giftcount']}元， +</span>
              <input class="form-control" type="number" value=""name="addgiftcount">
              <span class="input-group-addon">元</span>
            </div>
            <span class="help-block">输入需要新增或减少的金额，输入“-10”，等于减少10元，“+”为增，“-”为减。</span>
          </div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2 control-label">虚拟热度</label>
		<div class="col-sm-4">
            <div class="input-group">
              <input class="form-control" type="number" value="{$votedata['vheat']}"name="vheat">
              <span class="help-block">用户热度=真实热度+虚拟热度</span>
            </div>
          </div>
					
					
				</div>
				<div class="form-group">
          <label class="control-label col-sm-2 control-label">图片</label>
          <div class="col-sm-9">
				
				<div class="row">
				  <div class="col-xs-6 col-md-2">
					<a href="javascript:;" class="thumbnail imgbox0">
					  <img src="{if $votedata['img1']==""}resource/images/nopic-107.png{else} {media $votedata['img1']}{/if}" width="100%" >
					  <input type="hidden" value="{$votedata['img1']}" name="img1">
					</a>
					{if $formatdata['0']!="" && $nodownpic==1}
					<button type="button" class=" btn btn-sm btn-downpic" data-id="0"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 重新下载</button>
					{/if}
				  </div>
				  <div class="col-xs-6 col-md-2">
					<a href="javascript:;"  class="thumbnail imgbox1">
					  <img src="{if $votedata['img2']==""}resource/images/nopic-107.png{else} {media $votedata['img2']}{/if}" width="100%" >
					  <input type="hidden" value="{$votedata['img2']}" name="img2">
<em class="close delimage" style="position:absolute; top: 0px; right:0px;" title="删除这张图片" >×</em>
					  
					</a>
					{if $formatdata['1']!="" && $nodownpic==1}
					<button type="button" class=" btn btn-sm btn-downpic" data-id="1"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 重新下载</button>
					{/if}
				  </div>
				  <div class="col-xs-6 col-md-2">
					<a href="javascript:;"  class="thumbnail imgbox2">
					  <img src="{if $votedata['img3']==""}resource/images/nopic-107.png{else} {media $votedata['img3']}{/if}" width="100%" >
					  <input type="hidden" value="{$votedata['img3']}" name="img3">
	                  <em class="close delimage" style="position:absolute; top: 0px; right:0px;" title="删除这张图片" >×</em>
					</a>
					{if $formatdata['2']!="" && $nodownpic==1}
					<button type="button" class=" btn btn-sm btn-downpic" data-id="2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 重新下载</button>
					{/if}
				  </div>
				  <div class="col-xs-6 col-md-2">
					<a href="javascript:;"  class="thumbnail imgbox3">
					  <img src="{if $votedata['img4']==""}resource/images/nopic-107.png{else} {media $votedata['img4']}{/if}" width="100%" >
					  <input type="hidden" value="{$votedata['img4']}" name="img4">
	<em class="close delimage" style="position:absolute; top: 0px; right:0px;" title="删除这张图片" >×</em>
					</a>
					{if $formatdata['3']!="" && $nodownpic==1}
					<button type="button" class=" btn btn-sm btn-downpic" data-id="3"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 重新下载</button>
					{/if}
				  </div>

				  <div class="col-xs-6 col-md-2">
					<a href="javascript:;"  class="thumbnail imgbox4">
					  <img src="{if $votedata['img5']==""}resource/images/nopic-107.png{else} {media $votedata['img5']}{/if}" width="100%" >
					  <input type="hidden" value="{$votedata['img5']}" name="img5">
<em class="close delimage" style="position:absolute; top: 0px; right:0px;" title="删除这张图片" >×</em>
					</a>
					{if $formatdata['4']!="" && $nodownpic==1}
					<button type="button" class=" btn btn-sm btn-downpic" data-id="4"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 重新下载</button>
					{/if}
				  </div>
				  
				</div>
				<div class="help-block">重新下载，3天内有效，过期则不能下载！</div>
                
		  </div>
        </div>
	    
				<div class="form-group">
					<label class="control-label col-sm-2 control-label"><span class="text-danger"></span><span class="text-danger">*</span>宣言</label>
					<div class="col-sm-8 col-xs-12">
						<textarea name="introduction" class="form-control js-a" cols="30" rows="3">{$votedata['introduction']}</textarea>
					</div>
				</div>
		<div class="form-group">
          <label class="control-label col-sm-2 control-label">详情</label>
          <div class="col-sm-8">
		  {php echo tpl_ueditor('details', $votedata['details']);}		
           <div class="help-block">添加时，才显示！（至提供后台添加，支持HTML）</div> 
          </div>
        </div>
		<!--
			    <div class="form-group">
					<label class="control-label col-sm-2 control-label">认证</label>
					<div class="col-sm-8 col-xs-12">
						<label class="radio-inline">
						<input type="radio" name="attestation" value="0" {if $votedata['attestation']!=1} checked {/if} />否
					</label>
					<label class="radio-inline">
						<input type="radio" name="attestation" value="1" {if $votedata['attestation']=='1'} checked {/if}  />是
					</label>
					
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2 control-label">认证简介</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="atmsg" value="{$votedata['atmsg']}"/>
					</div>
				</div>
		-->
				<div class="form-group">
					<label class="control-label col-sm-2 control-label">审核</label>
					<div class="col-sm-8 col-xs-12">
						<label class="radio-inline">
						<input type="radio" name="status" value="0" {if $votedata['status']=='0'} checked {/if} />否
					</label>
					<label class="radio-inline">
						<input type="radio" name="status" value="1" {if $votedata['status']=='1'} checked {/if}  />是
					</label>
					
					</div>
				</div>
			
			</div>
          </div>
        </div>

		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script>
				require(['jquery', 'util'], function($, util){
					$(function(){
						// 对象绑定点击事件
						$('.thumbnail img').click(function(){
						    thimg=$(this);
							util.image('',function(data){
								thimg.attr("src",data['url']);
								thimg.next().val(data['attachment']);
							});
						});
					});



});
               </script>
<script>
	$('#form1').submit(function() {
		if(!$.trim($(':text[name="name"]').val())) {
			util.message('请填写姓名');
			return false;
		}
		if(!$.trim($(':text[name="img1"]'))) {
			util.message('请上传第一张图片');
			return false;
		}

		 
	});

	$('.btn-downpic').click(function(){
    var imgid=$(this).attr('data-id');
	var submitData = {
		imgid: imgid 
	};
	$.post('{php echo $this->createWebUrl("otherset", array("ty"=>"downpic","id"=>$_GPC['id'],"rid" => $_GPC["rid"]))}', submitData,
	function (data) {
		if (data.status == 1) { 	
				$(".imgbox"+imgid+" img").attr("src",data.imgurl);
				$(".imgbox"+imgid+" input").val(data.imgurl);
		} else{
		        alert(data.msg);  
		}
	},
	"json");
});

$('.delimage').click(function(){
   $(this).prev().val("");
   $(this).prev().prev().attr("src","");
});
</script>
{template 'common/footer'}
